# -*- coding: utf-8 -*-
# @Time    : 2024/8/27 10:15
# @Author  : Jonny
# @File    : LuckGitlabUserMain.py
# @Describe: LuckGitlabUserMain入口
from flask import Blueprint, current_app
import time
from luck.core.LuckConstant import LuckConstant
from luck.gitlab.LuckGitlabUserService import LuckGitlabUserService

luck_gitlab_user_bp = Blueprint('luck_gitlab_user', __name__)


# 检查服务器资源服务状态
@luck_gitlab_user_bp.route('/gitlab/user')
def gitlab_user_index():
    print(f'小程序 于 {time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time()))} 查看Gitlab User部署服务')

    return {
        "code": LuckConstant.CODE_SUCCESS,
        "data": [
            "/gitlab/user"
            , "/gitlab/user/readUserData"
        ],
        "msg": "Gitlab User部署服务"
    }

# 读取用户数据
@luck_gitlab_user_bp.route('/gitlab/user/readUserData')
def gitlab_user_read_user_data():
    config = current_app.config['CONFIG_DATA']
    config["gitlab_private_token"] = "-sqvLoLAgfWHQ8NSQcqr"
    gitlab_user_service = LuckGitlabUserService(config)
    gitlab_user_service.process_data()

    return {
        "code": LuckConstant.CODE_SUCCESS,
        "msg": "Gitlab User数据同步成功"
    }
